package Easy消失的数字;

import org.testng.annotations.Test;

import java.util.*;

public class Solution {
    public List<Integer> findDisappearedNumbers1(int[] nums) {
        List<Integer> list = new ArrayList<>();
        int n =nums.length;
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            map.put(nums[i],1);
        }
        for (int i = 1; i < n+1; i++) {
            if (map.getOrDefault(i,0)!=1)
                list.add(i);
        }
        return list;
    }

    public List<Integer> findDisappearedNumbers(int[] nums) {
        List<Integer> list = new ArrayList<>();
        List<Integer> list1 = new ArrayList<>();
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            list1.add(nums[i]);
        }
        for (int i = 1; i < n+1; i++) {

            if (!list1.contains(i))
                list.add(i);
        }
        return list;
    }
    @Test
    public void test(){
        int[] num = {4,3,2,7,8,2,3,1};
        List<Integer> list = findDisappearedNumbers1(num);
        System.out.println(list.toString());
    }
}
